package com.yiqi.liebang.feature.mine.view.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.suozhang.framework.framework.AM;
import com.suozhang.framework.utils.DateUtil;
import com.yiqi.liebang.R;
import com.yiqi.liebang.common.util.DateTool;
import com.yiqi.liebang.entity.bo.CouponBo;

import java.util.Date;
import java.util.List;

import static com.yiqi.liebang.common.util.AppUtil.getTwoDecimal;

public class CouponAdpter extends BaseQuickAdapter<CouponBo, BaseViewHolder> {
    private int type;

    public CouponAdpter(int type) {
        super(R.layout.item_coupon);
        this.type = type;
    }

    @Override
    protected void convert(BaseViewHolder helper, CouponBo item) {
        helper.setVisible(R.id.btn_coupon_use, type == 0 ? true : false)
                .setBackgroundRes(R.id.view_coupon_bg, type == 0 ? R.drawable.bg_user_coupon : R.drawable.bg_user_coupon_used)
                .setBackgroundColor(R.id.line_coupon, type == 0 ? AM.res().getColor(R.color.color_c6dcec) : AM.res().getColor(R.color.bg_normal2))
                .addOnClickListener(R.id.btn_coupon_use)
                .setText(R.id.tv_coupon_prize, getTwoDecimal(item.getOffMoney())+"" )
                .setText(R.id.tv_coupon_man, "满" + getTwoDecimal(item.getFullMoney()) + "元可用")
                .setText(R.id.tv_coupon_date, DateTool.milliseconds2String(item.getBeginTime()) + "~" + DateTool.milliseconds2String(item.getEndTime()))
                .setText(R.id.tv_coupon_name, item.getClassifyId().equals("0") ? "全部" : item.getClassify())
        ;

    }


}
